#ifndef GLCONNECTFOUR_H
#define GLCONNECTFOUR_H

#include <QGLWidget>
#include <QColor>
#include <QTimer>
#include <math.h>
#include "BoardColumn.h"
#include "Animation.h"

#include <QDebug>

#define LENGTH_CELL 75
#define RECT_WIDTH 3
#define RECT_HEIGHT 35
#define INNER_RADIUS 25
#define OUTER_RADIUS 30
#define COMPLEXITY 40
#define PI 3.141592653

#define GL_WIDTH (LENGTH_CELL * NUM_COLUMNS)
#define GL_HEIGHT (LENGTH_CELL * NUM_ROWS)

class GLConnectFour : public QGLWidget {

    Q_OBJECT

public:
    explicit GLConnectFour(QWidget *parent = 0);
    ~GLConnectFour();

signals:
    void animationFinished(Animation::AnimationMode mode);

public slots:
    void startAnimation(Animation::AnimationMode mode, int height, ConnectFour::Piece color);
    void compileColumnList(BoardColumn * column, int index);
    void compileWinList(ConnectFour::Win * win, ConnectFour::Direction direction, ConnectFour::Piece piece);
    void resetGL();

protected:
    void initializeGL();
    void paintGL();
    void resizeGL(int width, int height);

private slots:
    void updateAnimation();

private:
    void compileBoardList();
    void drawPiece(ConnectFour::Piece color);
    void drawCircle(int radius);

    GLuint boardCallList;
    GLuint columnCallLists[NUM_COLUMNS];
    GLuint winCallLists[NUM_WINS];

    QTimer * timer;
    Animation::Drop animation;
};

#endif // GLCONNECTFOUR_H
